<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>查看订单</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
  </head>
  
  <body>
  <div>
  	交易提醒<br>
  	待付款 (${notPayNum }) 待发货(${notSentNum }) 待确认收货(${notConfirmNum })  交易成功(${finishNum })
  </div>
  <br/>
  <br/>
  <br/>
  <br/>
  <div>
  	<table border=1>
  		<tr>
  			<td>订单号</td>
  			<td>商品名称</td>
  			<td>单价</td>
  			<td>数量</td>
  			<td>实付款</td>
  			<td>交易状态</td>
  			<td>交易操作</td>
  			<td>其它操作</td>
  		</tr>
  		<c:if test="${empty orders}">
  		<tr>
  			<td>没有记录</td>
  		</tr>
  		</c:if>
  		<c:forEach items="${orders}" var="order">
  		<tr>
  			<td rowspan="${fn:length(order.details)+1 }">${order.orderID }</td> 	 				
  			<c:forEach items="${order.details}" var="detail">  		
  			</tr><tr>
  			<td>${detail.productID }</td>
  			<td>${detail.productPrice }</td>
  			<td>${detail.productNumber }</td>
  			
  			</c:forEach>
  			
  			<td>${order.totalPrice }</td>
  			<c:choose>
  			<c:when test="${order.orderStatus == 'WAIT_BUYER_PAY'}">
  			<td>待买家付款</td>
  			<td>付款<br/><a href="ViewOrderDetailServlet?orderID=${order.orderID }">订单详情</a>
  			<br/><a href="CancelOrderServlet?orderID=${order.orderID }">取消订单</a></td>
  			<td></td>
  			</c:when>
  			<c:when test="${order.orderStatus == 'WAIT_BUYER_PAY'}">
  			<td>待卖家发货</td>
  			<td><br/><a href="ViewOrderDetailServlet?orderID=${order.orderID }">订单详情</a>
  			<br/><a href="CancelOrderServlet?orderID=${order.orderID }">取消订单</a></td>
  			<td></td>
  			</c:when>
  			<c:when test="${order.orderStatus == 'WAIT_BUYER_PAY'}">
  			<td>卖家已发货</td>
  			<td><br/><a href="ViewOrderDetailServlet?orderID=${order.orderID }">订单详情</a>
  			<br/>查看物流<br/>确认收货</td>
  			<td></td>
  			</c:when>
  			<c:when test="${order.orderStatus == 'WAIT_BUYER_PAY'}">
  			<td>交易成功</td>
  			<td><a href="ViewOrderDetailServlet?orderID=${order.orderID }">订单详情</a></td>
  			<td><a href="CancelOrderServlet?orderID=${order.orderID }">删除订单</a></td>
  			</c:when>
  			</c:choose>
  			
  		</tr>	
  		</c:forEach>
  		
  	</table>
  </div>  
  </body>
</html>
